
# 导包
import pymysql


#创还数据库连接
conn=pymysql.connect(host='192.168.121.134',
                     port=3306,
                     user='root',
                     password='123456',
                     database='litemall',
                     charset='utf8'
                     )

#获取游标对象
cursor=conn.cursor()

#执行sql
sql="select * from litemall_goods"
cursor.execute(sql)

# 一行
print(cursor.fetchone())
# 多行
print(cursor.fetchmany(3))
# 所有
print(cursor.fetchall())
# 关闭游标和数据库连接
cursor.close()
conn.close()




